<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录界面</title>
</head>
<body>
    <form method="POST" action="/login">
        <p>
            昵称:<input id="username" type="text" name="username">
        </p>
        <p>
            密码:<input id="password" type="password" name="password">
        </p>
        <p>cookie保存
            <select id="sel">
                <option class="option" value="1">1</option>
                <option class="option" value="3">3</option>
                <option class="option" value="5">5</option>
                <option class="option" value="7">7</option>
                <option class="option" value="9">9</option>
            </select>
            天
        </p>
        <input onclick="getInfo()" id="submit" type="submit" value="登录">
    </form>
</body>
<script src="./js/js.cookie.js"></script>
<script>
    //  if(Cookies.set('username')!=undefined){
    //     document.getElementById('username').value=Cookies.set('username');
    // }
    // if(Cookies.set('password')!=undefined){
    //     document.getElementById('password').value=Cookies.set('password');
    // }
    function getInfo(){
        var username=document.getElementById('username').value;
        var password=document.getElementById('password').value;
        // 获取索引
        var index=document.getElementById('sel').selectedIndex;
        var cookiesTime=document.getElementById('sel').options[index].value;
        var cookiesTime=Number(cookiesTime);
        // 保存数据到cookie
        Cookies.set('username',username,{expires:cookiesTime});
        Cookies.set('password',password,{expires:cookiesTime});
    }
</script>
</html>